package com.ycb.bookserver.Mapper;

import com.book.enumeration.OperationType;
import com.book.properties.JWTProperties;
import com.book.result.PageResult;
import com.book.result.Result;
import com.github.pagehelper.Page;
import com.ycb.book.dto.BookPageQueryDTO;
import com.ycb.book.entity.Book;
import com.ycb.book.vo.BookVO;
import com.ycb.bookserver.service.BookService;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ycb.bookserver.annotation.AutoFill;

import java.util.List;

@Mapper
public interface BookMapper {
    /**
     * 新增书籍
     * @param book
     * @return
     */
    @AutoFill(value = OperationType.INSERT)
    @Insert("insert into books (consignee,publisher_head,name,category,image,msg,price,status,create_time,update_time)" +
            "values " +
            "(#{consignee},#{publisherHead},#{name},#{category},#{image},#{msg},#{price},#{status},#{createTime},#{updateTime})")
    void add(Book book);

    /**
     * id查询书籍
     * @param id
     * @return
     */
    @Select("select * from books where id=#{id}")
    Book getById(Long id);

    /**
     * 修改书籍信息
     * @param book
     */
    @AutoFill(value = OperationType.UPDATE)
    void modify(Book book);

    /**
     * 删除书籍
     * @param id
     */
    @Delete("delete from books where id=#{id}")
    void delete(Long id);

    /**
     * 查询书籍
     * @param bookPageQueryDTO
     * @return
     */
    Page<BookVO> search(BookPageQueryDTO bookPageQueryDTO);


    void deleteByIds(List<Long> ids);

    @Select("select * from BOOKS")
    List<Book> allBook();

    List<Book> searchByPartName(String partName);
}
